<template>
	<div id="makegold">
		<div id="header">
			<img @click="$router.go(-1)" src="../../static/img/return.png"/>
			<p>赚金币</p>
		</div>
		<!-------签到-------->
		<div class="makegold_1">
			<img src="../../static/img/makegold-01.png"/>
			<div class="sign_in">
				<div class="mygold">
					<p>我的金币：<span>{{user.userWallet.coins}}</span></p>
					<p>连续签到送5/10/15/20（封顶）</p>
				</div>
				<div @click="signIn" v-if="user.isTodaySign == 0" class="signIn_btn">
					<img src="../../static/img/makegold-02.png"/>
					<p>签到+{{coinsAdd}}</p>
				</div>
				<div v-else class="signIn_btn">
					<img src="../../static/img/makegold-03.png"/>
					<p class="signIn_btn2">已签到</p>
				</div>
			</div>
		</div>
		<!--------赚金币，花金币切换选项卡----------->
		<ul class="gold_type">
			<li @click="goldType = 1" :class="goldType == 1?'type_active':''">
				赚金币
			</li>
			<li @click="goldType = 2" :class="goldType == 2?'type_active':''">
				花金币
			</li>
		</ul>
		<!---------赚金币途径------------->
		<div v-if="goldType == 1" class="makegold_2">
			<!--<p><span>赚金币</span>只要你做就送金币！</p>-->
			<ul>
				<li v-for="item in makeWayList" class="way_item">
					<div class="way_left">
						<img :src="item.Img"/>
						<div class="way_text">
							<p>{{item.title}}</p>
							<p>{{item.condition}}</p>
						</div>
					</div>
					<div class="way_right">
						<p><img src="../../static/img/makegold-04.png"/>+{{item.reward}}</p>
						<router-link v-if="item.isget == 0" :to="item.link">领取金币</router-link>
						<a style="background-color: #787878" v-else>已完成</a>
					</div>
				</li>
			</ul>
		</div>
		<!----------花金币-------------->
		<ul v-else-if="goldType == 2" class="spendgold">
			<li>
				<div class="spend_left">
					<img src="../../static/img/spendgold-01.png"/>
					<p>金币必中</p>
				</div>
				<router-link to="/home/good">去兑换</router-link>
			</li>
			<li>
				<div class="spend_left">
					<img src="../../static/img/spendgold-02.png"/>
					<p>至尊会员</p>
				</div>
				<router-link to="/user/vip">去兑换</router-link>
			</li>
			<li>
				<div class="spend_left">
					<img src="../../static/img/spendgold-03.png"/>
					<p>金币抽奖</p>
				</div>
				<router-link to="/user/luckyDraw">去抽奖</router-link>
			</li>
		</ul>
		<!-------签到成功----------->
		<div @click="signIn_succ = false, getUserInfo()" v-show="signIn_succ" id="signIn_succ">
			<div class="signIn_succ" @click="getUserInfo()">
				<img src="../../static/img/makegold-11.png"/>
				<p>本次签到获得{{coinsAdd}}金币奖励</p>
			</div>
		</div>
	</div>
</template>

<script>
export default{
	name: 'makegold',
	data:function(){
		return{
			goldType: 1,//1 赚金币，2  花金币
			makeWayList: [
//				{
//					title: "邀请商家",
//					condition: "邀请商家成功发布活动",
//					Img: './static/img/makegold-05.png',
//					reward: 40200,
//					link: "/user/shareAgent",
//					isget: 0	// 是否已领取 0 否 1 是
//				},
//				{
//					title: "邀请粉丝",
//					condition: "粉丝注册申请",
//					Img: './static/img/makegold-06.png',
//					reward: 200,
//					link: "/user/shareUser",
//					isget: 0	// 是否已领取 0 否 1 是
//				},
				{
					title: "金币充值",
					condition: "1元=200金币",
					Img: './static/img/makegold-07.png',
					reward: '2000起',
					link: "/user/recharge",
					isget: 0	// 是否已领取 0 否 1 是
				},
				{
					title: "申请试用",
					condition: "单日申请10次试用",
					Img: './static/img/makegold-08.png',
					reward: 200,
					link: "/home/good",
					isget: 0	// 是否已领取 0 否 1 是
				},
				{
					title: "开通会员",
					condition: "会员期间每月送",
					Img: './static/img/makegold-09.png',
					reward: 368,
					link: "/user/vip",
					isget: 0	// 是否已领取 0 否 1 是
				},
				{
					title: "注册账号",
					condition: "一次性赠送",
					Img: './static/img/makegold-10.png',
					reward: 200,
					link: "",
					isget: 1	// 是否已领取 0 否 1 是
				}
			],	// 赚取金币方式
			user: {
				userWallet: {
					coins: 0
				}
			},	// 用户信息
			coinsAdd: '',	// 今天签到奖励
			signIn_succ: false	// 签到成功弹窗
		}
	},
	methods:{
		// 获取用户信息
		getUserInfo: function(){
			var _this = this;
			this.$axios.post("/user/info/getUserInfo").then(function(res){
				var data = res.data;
			    if(data.message == "succ"){
			    	_this.user = data.result;
			    	// 今日申请获得金币数
			    	if(data.result.continuousSigndays <= 4){
			    		_this.coinsAdd = 5 * data.result.continuousSigndays;
			    	}else{
			    		_this.coinsAdd = 20;
			    	}
			    	// 今日申请是否大于等于10
			    	if(data.result.todayApply >= 10){
			    		_this.makeWayList[3].isget = 1;
			    	}
			    	// 是否会员
			    	if(data.result.isMember == 1){
			    		_this.makeWayList[4].isget = 1;
			    	}
			    }else{
			    	_this.$alert(data.result);
			    }
			}
			).catch(function (error) {
				console.log(error);
			});
		},
		// 签到
		signIn: function(){
			var _this = this;
			this.$axios.post("/user/info/signIn").then(function(res){
				var data = res.data;
			    if(data.message == "succ"){
			    	_this.signIn_succ = true;
			    }else{
			    	_this.$alert(data.result);
			    }
			}
			).catch(function (error) {
				console.log(error);
			});
		}
	},
	created: function(){
		this.getUserInfo();
		if(this.$route.query.type){
			this.goldType = this.$route.query.type;
		}
	}
}
</script>

<style scoped>
/* ========== */
/* = Header = */
/* ========== */
#header{
	width: 100%;
	background-color: #fff;
	position: fixed;
	top: 0;
	left: 0;
	height: 4rem;
	display: flex;
	align-items: center;
	justify-content: center;
	border-bottom: 1px solid #EEEEEE;
	font-size: 1.6rem;
	color: #4F4F4F;
	box-sizing: border-box;
	z-index: 10;
}
#header img{
	height: 2rem;
	display: block;
	position: absolute;
	top: 1rem;
	left: 2rem;
}
#makegold{
	height: 100%;
	padding: 4rem 0;
	box-sizing: border-box;
	background-color: #fff;
}
/*-----------签到--------------*/
.makegold_1{
	position: relative;
	padding: 1rem;
	box-sizing: border-box;
	background-color: #fff;
}
.makegold_1>img{
	width: 100%;
	display: block;
}
.sign_in{
	position: absolute;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: flex-end;
	padding: 0 2rem;
	box-sizing: border-box;
}
.mygold p:first-child{
	color: #FFF67B;
	text-shadow: 1px 1px 1px #3494DB;
	font-size: 1.2rem;
}
.mygold p:first-child span{
	font-size: 2rem;
	margin-left: 0.5rem;
}
.mygold p:last-child{
	font-size: 1.2rem;
	color: #0C46A4;
	margin-top: 0.5rem;
}
.signIn_btn{
	height: 3rem;
	position: relative;
	margin-top: 1rem;
}
.signIn_btn img{
	height: 100%;
	display: block;
}
.signIn_btn p{
	font-size: 1.4rem;
	color: #FF7700;
	position: absolute;
	height: 3rem;
	line-height: 3rem;
	top: 0;
	left: 1.5rem;
}
.signIn_btn p.signIn_btn2{
	color: #FFFFFF;
}
/*-------赚金币，花金币选项卡---------*/
.gold_type{
	display: flex;
	justify-content: space-around;
	border-top: 1px solid #EEEEEE;
	background-color: #fff;
}
.gold_type li{
	width: 10rem;
	height: 3rem;
	border-bottom: 1px solid transparent;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.4rem;
	color: #4F4F4F;
}
.gold_type li.type_active{
	color: #FF6565;
	border-bottom: 1px solid #FF6565;
}
/*-----------赚金币-------------*/
.makegold_2{
	background-color: #fff;
	border-top: 1rem solid #F5F5F5;
}
.makegold_2>p{
	height: 3.4rem;
	display: flex;
	align-items: center;
	padding-left: 1rem;
	box-sizing: border-box;
	color: #A9A9A9;
	font-size: 1rem;
}
.makegold_2>p span{
	font-size: 1.6rem;
	color: #FD921D;
	margin-right: 1rem;
}
.way_item{
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1rem;
	border-top: 1px solid #EEEEEE;
	box-sizing: border-box;
}
.way_item .way_left{
	display: flex;
	align-items: center;
}
.way_item .way_left img{
	height: 4rem;
	display: block;
	margin-right: 1rem;
}
.way_item .way_left .way_text{
	height: 4rem;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}
.way_item .way_left .way_text p:first-child{
	color: #4F4F4F;
	font-size: 1.4rem;
	white-space: nowrap;
}
.way_item .way_left .way_text p:last-child{
	color: #A9A9A9;
	font-size: 1rem;
	width: 8rem;
	white-space: nowrap;
}
.way_item .way_right{
	display: flex;
	align-items: center;
}
.way_item .way_right p{
	display: flex;
	align-items: center;
	color: #787878;
	font-size: 1.2rem;
	margin-right: 2rem;
	white-space: nowrap;
}
.way_item .way_right p img{
	height: 1.2rem;
	display: block;
	margin-right: 0.3rem;
}
.way_item .way_right a{
	background-color: #FFBB10;
	color: #FFFFFF;
	width: 7rem;
	height: 2.2rem;
	line-height: 2.2rem;
	border-radius: 3px;
	box-sizing: border-box;
	font-size: 1.2rem;
	text-align: center;
}
/*--------花金币----------*/
.spendgold{
	border-top: 1rem solid #F5F5F5;
}
.spendgold li{
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1rem 1.5rem;
	border-bottom: 1px solid #EEEEEE;
	box-sizing: border-box;
}
.spendgold li .spend_left{
	display: flex;
	align-items: center;
	color: #4F4F4F;
	font-size: 1.2rem;
}
.spendgold li .spend_left img{
	height: 4rem;
	display: block;
	margin-right: 1rem;
}
.spendgold li a{
	background-color: #FFBB10;
	color: #FFFFFF;
	width: 7rem;
	height: 2.6rem;
	border-radius: 3px;
	text-align: center;
	line-height: 2.6rem;
	font-size: 1.2rem;
}
/*--------签到成功---------*/
#signIn_succ{
	width: 100%;
	height: 100%;
	background-color: rgba(0,0,0,0.7);
	display: flex;
	align-items: center;
	justify-content: center;
	position: fixed;
	top: 0;
	left: 0;
	z-index: 11;
}
.signIn_succ{
	width: 100%;
	position: relative;
	
}
.signIn_succ img{
	width: 100%;
	display: block;
}
.signIn_succ p{
	color: #FFFFFF;
	font-size: 1.6rem;
	position: absolute;
	width: 100%;
	text-align: center;
	bottom: 24%;
}

</style>